package com.hontech.libratest.conn

import com.hontech.libratest.utils.Frame
import com.hontech.libratest.utils.SerialType
import kotlinx.coroutines.CompletableDeferred

class ConnExecTask(
    val req: Int,
    val args: Array<SerialType>,
    val timeout: Long,
    val future: CompletableDeferred<Frame>
) : Runnable {

    override fun run() {

        try {
            val frame = Device.send(Device.destAddr, req, args, timeout)
            future.complete(frame)
        } catch (e: Exception) {
            e.printStackTrace()
            future.completeExceptionally(e)
        }
    }
}

